/**
 *    @file       baseconf.cpp
 *
 *    @brief      
 *    @details
 *
 *    @version    1.0
 *    @date       02/16/2014 10:39:21 AM
 *
 *    @author     Theophilus (), wangtf418@gmail.com 
 */
#include "baseconf.h"

#define BASE_CONF_FILENAME "conf/base.conf"

baseconf::baseconf()
	: confmgr<baseconf_item>(BASE_CONF_FILENAME)
{

}

baseconf::~baseconf()
{

}

bf_int_t baseconf::read_conf_items()
{
	std::string str_out;
	bf_int64_t num_out;

	IF_ERR_RETURN(read_ip_item("Server", "SrvIp", "0.0.0.0", m_conf.m_srvip))
	IF_ERR_RETURN(read_int_item("Server", "SrvPort", 80, num_out, 0, BF_USHORT_MAX))
	m_conf.m_srvport = (bf_ushort_t)num_out;

	IF_ERR_RETURN(read_ip_item("Server", "MaintainIp", "127.0.0.1", m_conf.m_maintain_ip))
	IF_ERR_RETURN(read_int_item("Server", "MaintainPort", 10080, num_out, 0, BF_USHORT_MAX))
	m_conf.m_maintain_port = (bf_ushort_t)num_out;

	IF_ERR_RETURN(read_int_item("Server", "MaxFdSize", 100000, num_out, 1, 10000000))
	m_conf.m_max_fd_size = (bf_uint_t)num_out;
	IF_ERR_RETURN(read_int_item("Server", "SocketTaskTimeout", 60, num_out, 1, 10000000))
	m_conf.m_sockettask_timeout = (bf_time_t)num_out;
	IF_ERR_RETURN(read_int_item("Server", "LSocketTaskTimeout", 60, num_out, 1, 10000000))
	m_conf.m_lsockettask_timeout = (bf_time_t)num_out;

	IF_ERR_RETURN(read_int_item("Server", "NetIOThreadNum", 1, num_out, 1, 10000000))
	m_conf.m_netio_thdnum = (bf_uint32_t)num_out;
	IF_ERR_RETURN(read_int_item("Server", "ProcThreadNum", 1, num_out, 1, 10000000))
	m_conf.m_proc_thdnum = (bf_uint32_t)num_out;
	IF_ERR_RETURN(read_int_item("Server", "DBThreadNum", 1, num_out, 1, 10000000))
	m_conf.m_db_thdnum = (bf_uint32_t)num_out;
	IF_ERR_RETURN(read_int_item("Server", "FileThreadNum", 1, num_out, 1, 10000000))
	m_conf.m_file_thdnum = (bf_uint32_t)num_out;
	IF_ERR_RETURN(read_int_item("Server", "ClientThreadNum", 1, num_out, 1, 10000000))
	m_conf.m_client_thdnum = (bf_uint32_t)num_out;

	return BF_OK;
}

